home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer)…68k, x86, SPARC, PA-RISC] / NeXTSTEP 3.3 Dev Intel.iso / NextDeveloper / Headers / driverkit / i386 / ioPorts.h < prev    next >
Text File  |  1993-08-21  |  2KB  |  119 lines

  1. /*
  2.  * Copyright (c) 1993 NeXT Computer, Inc.
  3.  *
  4.  * Primatives for IO port access.
  5.  *
  6.  * HISTORY
  7.  *
  8.  * 16Feb93 David E. Bohman at NeXT
  9.  *    Created.
  10.  */
  11.  
  12. #ifndef _DRIVERKIT_I386_IOPORTS_
  13. #define _DRIVERKIT_I386_IOPORTS_
  14.  
  15. #import <driverkit/i386/driverTypes.h>
  16.  
  17. static __inline__
  18. unsigned char
  19. inb(
  20.     IOEISAPortAddress    port
  21. )
  22. {
  23.     unsigned char    data;
  24.     
  25.     asm volatile(
  26.         "inb %1,%0"
  27.     
  28.     : "=a" (data)
  29.     : "d" (port));
  30.     
  31.     return (data);
  32. }
  33.  
  34. static __inline__
  35. unsigned short
  36. inw(
  37.     IOEISAPortAddress    port
  38. )
  39. {
  40.     unsigned short    data;
  41.     
  42.     asm volatile(
  43.         "inw %1,%0"
  44.     
  45.     : "=a" (data)
  46.     : "d" (port));
  47.     
  48.     return (data);
  49. }
  50.  
  51. static __inline__
  52. unsigned long
  53. inl(
  54.     IOEISAPortAddress    port
  55. )
  56. {
  57.     unsigned long    data;
  58.     
  59.     asm volatile(
  60.         "inl %1,%0"
  61.     
  62.     : "=a" (data)
  63.     : "d" (port));
  64.     
  65.     return (data);
  66. }
  67.  
  68. static __inline__
  69. void
  70. outb(
  71.     IOEISAPortAddress    port,
  72.     unsigned char    data
  73. )
  74. {
  75.     static int        xxx;
  76.  
  77.     asm volatile(
  78.         "outb %2,%1; lock; incl %0"
  79.     
  80.     : "=m" (xxx)
  81.     : "d" (port), "a" (data), "0" (xxx)
  82.     : "cc");
  83. }
  84.  
  85. static __inline__
  86. void
  87. outw(
  88.     IOEISAPortAddress    port,
  89.     unsigned short    data
  90. )
  91. {
  92.     static int        xxx;
  93.  
  94.     asm volatile(
  95.         "outw %2,%1; lock; incl %0"
  96.     
  97.     : "=m" (xxx)
  98.     : "d" (port), "a" (data), "0" (xxx)
  99.     : "cc");
  100. }
  101.  
  102. static __inline__
  103. void
  104. outl(
  105.     IOEISAPortAddress    port,
  106.     unsigned long    data
  107. )
  108. {
  109.     static int        xxx;
  110.  
  111.     asm volatile(
  112.         "outl %2,%1; lock; incl %0"
  113.     
  114.     : "=m" (xxx)
  115.     : "d" (port), "a" (data), "0" (xxx)
  116.     : "cc");
  117. }
  118. #endif    _DRIVERKIT_I386_IOPORTS_
  119.